<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>定位</title>
    <style>
        /* 设置大盒子 */
      .box1 { 
        width: 500px;
        height: 500px;
        margin-left: 100px;
        position:relative;
      }
      .box2 {
        width: 110px;
        height: 110px;
        background-color: rgb(247, 64, 9);
        position: absolute;
        left:280px;
        top: 130px; 
      }
      .box3 {
        position: absolute;
        width: 50px;
        height: 50px;
        background-color: rgb(20, 19, 20);
        position: relative;
        top:100px;
       left: 290px; 
      }
      .box4 {
        width: 80px;
        height: 80px;
        background-color: rgb(43, 188, 245);
        /* 设置层级 */
        z-index: 2;
        position: absolute;
        top: 130px;
        right: 180px;    
      }
      .box5{
        width: 300px;
        height: 100px;
        background-color: brown;
        z-index: 3;
        position: absolute;
        top: 150px;       
      }
      /* 设置相对兄弟元素进行定位  */
      .box{
        position: relative;
      }     
        /* 层级最高的元素 */
      .boxa{
        width: 20px;
        height: 20px;
        background-color: yellow;
        position: absolute;
        right: 0px;
        bottom: 0px;
      }
    </style>
  </head>
  <body>
    <div class="box1">
      <div class="box2"></div>
      <div class="box3"></div>
      <div class="box4"></div>
      <div class="box5">
          <div class="box"></div>
          <div class="boxa"></div>
      </div>
    </div>
  </body>
</html>